﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using S.Produce.Read.Api.Application.Commands.BreedingCommands;

namespace S.Produce.Read.Api.Controllers
{
    /// <summary>
    /// 配种控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingsController : ControllerBase
    {
        private readonly IMediator mediator;

        public BreedingsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取配种信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetBreedingList([FromQuery] BreedingSelectCommand command)
        {
            return Ok(await mediator.Send(command));
        }

            /// <summary>
        /// 获取所有配种信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetBreedAllInfo([FromQuery] HintBreedingCommands command)
        {
            return Ok(await mediator.Send(command));
        }


        /// <summary>
        /// 回填配种信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetBreedingInfo([FromQuery]breedingBackfillCommand command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 根据耳号获取配种信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetBreedingForEar([FromQuery]BreedingEarCommand command)
        {
            return Ok(await mediator.Send(command));
        }
    }
}
